import com.jogamp.opengl.GLCapabilities;
import com.jogamp.opengl.GLProfile;
import com.jogamp.opengl.awt.GLCanvas;
import com.jogamp.opengl.util.FPSAnimator;

import javax.swing.*;
import java.awt.*;

/**
 * Created by WheelChen on 2017/5/18.
 */
public class main {
    public static void main(String[] args) {
        //getting the capabilities object of GL2 profile
        final GLProfile profile = GLProfile.get(GLProfile.GL2);
        GLCapabilities capabilities = new GLCapabilities(profile);
        // The canvas
        final GLCanvas glcanvas = new GLCanvas(capabilities);

        // ------------------------------------------ 创建对象
        Line l = new Line();
        Triangle t = new Triangle();
        Quad q = new Quad();
        TriangleStrip ts = new TriangleStrip();
        Polygon p = new Polygon();
        TriangleRotation triangleRotation = new TriangleRotation();
        PolygonLighting polygonLighting = new PolygonLighting();
        Line3d line3d = new Line3d();
        Triangle3d triangle3d = new Triangle3d();

        glcanvas.addGLEventListener(q);
        glcanvas.addGLEventListener(t);

        glcanvas.setSize(800, 800);

        //creating frame
        final JFrame frame = new JFrame ("straight Line");
        //adding canvas to frame
        frame.getContentPane().add(glcanvas);
        frame.setSize(frame.getContentPane().getPreferredSize());
        Dimension displaySize = Toolkit.getDefaultToolkit().getScreenSize(); // 获得显示器大小对象
        Dimension frameSize = frame.getSize();             // 获得窗口大小对象
        if (frameSize.width > displaySize.width)
            frameSize.width = displaySize.width;           // 窗口的宽度不能大于显示器的宽度
        if (frameSize.height > displaySize.height)
            frameSize.height = displaySize.height;          // 窗口的高度不能大于显示器的高度
        frame.setLocation((displaySize.width - frameSize.width) / 2,
                (displaySize.height - frameSize.height) / 2); // 设置窗口居中显示器显示

        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        //Instantiating and Initiating Animator
        final FPSAnimator animator = new FPSAnimator( glcanvas, 300,true );
        animator.start();

//        //creating frame
//        final Frame frame2 = new Frame( " Basic Frame" );
//        //adding canvas to frame
//        frame2.add( glcanvas );
//        frame2.setVisible( true );



    }//end of main
}
